<?php

namespace Database\Seeders;

use App\Models\Admin;
use App\Models\User;
use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
         \App\Models\User::factory(3)->create();
         \App\Models\Admin::factory(3)->create();
         
	    $admin = Admin::query()->with(['chatUser'])->get();
	    $user = User::query()->with(['chatUser'])->get();

	   foreach ($admin as $v) {
	   	if (!$v->chatUser) {
	   		$v->chatUser()->create();
	    }
	   }
	   
	   foreach ($user as $v) {
	   	if (!$v->chatUser) {
	   		$v->chatUser()->create();
	    }
	   }
    }
}
